<script>
    import {mapMutations} from 'vuex'
	export default {
        methods:{
            ...mapMutations(['login'])
        },
		onLaunch: function() {
          // let  user={
          //      userId:"8a80cb816c27db75016c27dc68e90000",
          //       token:"eyJhbGciOiJIUzI1NiIsIlR5cGUiOiJKd3QiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE1Njk5OTE3NTEsImFjY291bnQiOiIzMTE4MDAzNTY0In0.VXUcEUTOn5GBbS1wWS016WX5t-hM2evWAImCRe2xLUE",
          //       pointId:'',
          //       userName:''
          //   }
          //     uni.setStorageSync('userInfos', user);
			console.log('App Launch')
            
            let userInfos = uni.getStorageSync("userInfos")||'';
            
              let c = this;
            
            uni.request({
                 url:"https://07cr7.live/setgoals/getMygoals?type=0&PageNum=1&PageLimit=5",
                 header:{
                     adminToken:userInfos.token
                 },
                 success(res) {
                     
                     if(res.statusCode == 401){
                         
                         console.log("失效了")
                         
                         uni.removeStorageSync('userInfos');
                     }
                     }
            })
            
       
            console.log(userInfos)
            
            if(userInfos.userId){
                            uni.getStorage({
                                key:"userInfos",
                                success(res) {
                                    console.log(res.data)
                                   c.login(res.data);       
                                }
                            })
                        } 
           
			
// 			uni.getNetworkType({
//     success: function (res) {
//         console.log(res.networkType);
// 		if(res.networkType == none){
// 			
// 			uni.showToast({
// 			title:"请检查网络连接"	,
// 			position:center	,
// 			success() {
// 				console.log("请检查网络连接");
// 			}
// });
// 		}
//     }
// });

// #ifdef APP-PLUS  
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {  
    uni.request({  
        url: 'http://106.52.13.151/update/',  
        data: {  
            version: widgetInfo.version,  
            name: widgetInfo.name  
        },  
        success: (result) => {  
            console.log(result.data);
            var data = result.data;  
            if (data.update && data.wgtUrl) {  
                uni.downloadFile({  
                    url: data.wgtUrl,  
                    success: (downloadResult) => {  
                        if (downloadResult.statusCode === 200) {  
                            plus.runtime.install(downloadResult.tempFilePath, {  
                                force: false  
                            }, function() {  
                                console.log('install success...');  
                                plus.runtime.restart();  
                            }, function(e) {  
                                console.error('install fail...');  
                            });  
                        }  
                    }  
                });  
            }  
        }  
    });  
});  
// #endif

// uni.request({
//     url:"http://192.168.1.209:4000",
//     method:"GET",
//     data:{
//         name:"邑点邑滴",
//         version:"1.0.0"
//     },
//     success(res) {
//       console.log(res.data);  
//     }
// })
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	@import url("./common/uni.css");
	@import url("./common/colorui/main.css");
	@import url("./common/colorui/icon.css");
	@import url("./common/colorui/animation.css");
    @import url("/components/gaoyia-parse/parse.css");
</style>
